<?php
/**
 * Created by PhpStorm.
 * User: ljc
 * Date: 2018/7/29
 * Time: 14:49
 */
namespace app;
use wechat\build\Button;
use wechat\Wx;

class Entry
{
	private $wx;
	public function __construct () {
		$config=[
			'token'=>'ljcljc',
			'appID'=>'wx1df172ef6257d13b',
			'appsecret'=>'87aba432ca0cf63896dfbc1dd3181b12'
		];
		$this->wx=new Wx($config);
		$this->wx->valid ();
	}

	public function handle(){
		$message=$this->wx->getMessage ();
		$m=$this->wx->instance('message');
		if($m->isImage($message)){
			$m->image($message->MediaId);
		}else if($m->isText($message)){
			switch ($message->Content){
				case '电话':
					$m->text('110');
					break;
				default:$m->text('我不知道你在说什么');
			}
		}
		if($m->isEvent($message)){
			$m->text('您点击了菜单');
		}

	//	$post = '{
 //    "button":[
 //    {
 //         "type":"view",
 //         "name":"后盾网",
 //         "url":"https://www.baidu.com"
 //     },
 //     {
 //          "name":"菜单",
 //          "sub_button":[
 //          {
 //              "type":"view",
 //              "name":"后盾人",
 //              "url":"http://www.houdunren.com/"
 //           },
 //           {
 //              "type":"click",
 //              "name":"赞一下我们",
 //              "key":"V1001_GOOD"
 //           }]
 //      }]
 //}';
	//	(new Button())->create($post);
		//(new Button())->look();
		//$this->wx->instance ('button')->delButton();
		//$post='{"tag":{"name":"广东"} }';
		//$this->wx->instance ('user')->createTag($post);
		//$this->wx->instance ('user')->getTag();
		//$post='{"tag":{"id":100,"name":"福建人"}}';
		//$this->wx->instance ('user')->editTag($post);
		//$post='{"tagid":0}';
		//$this->wx->instance ('user')->getFans($post);
		//$this->wx->instance ('user')->getUserInfo();
		$data=$this->wx->instance ('jssdk')->makeSign();
		include 'app/view/index.html';
	}
}